/**
 * Created by JLB1 on 2017/2/18.
 */


import React, {Component, PropTypes} from 'react'
import ReactDOM from "react-dom"
import { addErrorListener } from "../../lib/handleError"
import weixinShare from "../../lib/weixinShare"
import AJAX from "../../lib/ajax"
import Tools from "../../lib/tools"
require('../../styles/common.less');
require('../../styles/lux.less');
require('../../styles/resetWeui.less');
require('./OthersPickup.less');

class OthersPickup extends Component {
    constructor(props) {
        super(props);
        this.state = {
            data: {
                adImgSrc: '',
                addr: '',
                in_time: '',
                exp_code: '',
                exp_name: '',
                open_code: '',
                contact_phone: '',
                contact_desc: '',
                settle_amount: '',
            },
        }
    }

    componentWillMount() {
        addErrorListener()()
        weixinShare.hideAll()
        const id = Tools.getParams().order_id;
        const sign = Tools.getParams().sign;
        const aditem_id = Tools.getParams().aditem_id;
        AJAX.request("share_detail", {order_id:id,sign:sign,aditem_id:aditem_id}, (data) => {
            if (data.code === 0) {
                const dataBody = data.body;
                let copyData = {
                    adImgSrc: dataBody.advert.img,
                    addr: dataBody.storage_info.addr,
                    in_time:dataBody.in_time,
                    exp_code: dataBody.exp_code,
                    exp_name: dataBody.exp_name,
                    open_code: dataBody.open_code,
                    contact_phone: dataBody.contact_phone,
                    contact_desc: dataBody.contact_desc,
                    settle_amount: (dataBody.settle_amount / 100).toFixed(2),
                };
                this.setState({
                    data: copyData,
                })
            }
        })

    }

    componentDidMount() {
        AJAX.appendBaiduAnalysis()
    }

    render() {

        return (
            <div className="detailBg">
                <div className="expressDetailBox">
                    <div className="paddingBox">
                        <div className="expressDetailItem">
                            <p className="expressDetail_title">取件密码：</p>
                            <p className="expressDetail_info">{this.state.data.open_code}</p>
                        </div>
                    </div>
                    <div className="paddingBox beforeLine">
                        <div className="expressDetailItem">
                            <p className="expressDetail_title">存放位置：</p>
                            <p className="expressDetail_info">{this.state.data.addr}</p>
                        </div>
                    </div>

                    <div className="paddingBox beforeLine">
                        <div className="expressDetailItem ">
                            <p className="expressDetail_title">{this.state.data.exp_name}</p>
                            <p className="expressDetail_info">{this.state.data.exp_code}</p>
                        </div>
                        <div className="expressDetailItem">
                            <p className="expressDetail_title">投递时间：</p>
                            <p className="expressDetail_info">{this.state.data.in_time}</p>
                        </div>
                        <div className="expressDetailItem">
                            <p className="expressDetail_title">取件费用：</p>
                            <p className="expressDetail_info colorRed">{this.state.data.settle_amount} 元</p>
                        </div>
                        <div className="expressDetailItem">
                            <p className="expressDetail_title">{this.state.data.contact_desc}</p>
                            <p className="expressDetail_info"><a
                                href="tel:010-673654">{this.state.data.contact_phone}</a></p>
                        </div>
                    </div>
                </div>


                <div className="banner-box">
                    <div className='banner' style={{backgroundImage: "url(" + this.state.data.adImgSrc + ")"}}>

                    </div>
                </div>
            </div>
        )
    }
}
ReactDOM.render(<OthersPickup />, document.getElementById('app'));
if (module.hot) {
    module.hot.accept();
}

